######################################################################
#
# wt::server package
#
######################################################################

package provide wt::server 1

namespace eval ::wt::server:: {
}

proc ::wt::server::handleError {} {
  wt::status wt::statusCodes::HTTP_INTERNAL_SERVER_ERROR

  set buf "<html>\n<head><title>Error</title></head>\n<body>\n"
  append buf "<h1>Error</h1>"
  append buf "<p>Date: "
  append buf [clock format [clock seconds] -format "%Y-%m-%d %T %Z"]
  append buf "</p>\n"

  global errorInfo

  if {[string length $errorInfo]} {
    append buf "<p>An error occurred while processing this request:</p>"
    append buf "<p><ul><pre>"
    append buf [htmlEncode $errorInfo]
    append buf "</ul></pre></p>"
  } else {
    append buf "<p>An error occurred while processing this request.</p>"
  }

  append buf "<p>Please contact the webmaster for further assistance.</p>"
  append buf "\n</body>\n</html>"

  puts $buf

  flush stdout
}
